package com.aiju.widgit.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;

import com.aiju.base.R;
import com.aiju.base.dialog.BaseDialog;
import com.aiju.common.PixValue;

/**
 * @author: 佐为
 * @date: 2017-02-10 16:05
 * @version: V1.0
 * @Description: 描述
 */
public class PermissionDialog extends BaseDialog {

    public PermissionDialog(Context context) {
        super(context);
    }

    @Override
    protected int getDialogStyleId() {
        return R.style.dialog;
    }

    @Override
    protected View getView() {
        View inflate = mLayoutInflater.inflate(R.layout.dialog_permission, null);
        inflate.findViewById(R.id.ly_discount).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnSimpleClick != null) {
                    mOnSimpleClick.onSubmit();
                    dismiss();
                }
            }
        });
        return inflate;
    }

    /**
     * 设置对话框LayoutParams
     *
     * @return
     */
    public PermissionDialog setLayoutParams() {
        WindowManager.LayoutParams lp = getDialogWindow().getAttributes();
        lp.width = PixValue.dp.valueOf(310);
        lp.height = PixValue.dp.valueOf(465);
        getDialogWindow().setGravity(Gravity.CENTER);
        getDialogWindow().setAttributes(lp);
        return this;
    }

    private OnSimpleClick mOnSimpleClick;

    public PermissionDialog setOnSimpleClick(OnSimpleClick onSimpleClick) {
        this.mOnSimpleClick = onSimpleClick;
        return this;
    }

    public interface OnSimpleClick {
        void onCancel();

        void onSubmit();
    }
}
